package com.wchen.gdoc.generate.config;

import com.alibaba.fastjson.JSONObject;

import java.util.Properties;

/**
 * 文档配置
 *
 * @author  wchen
 * @date    2019/11/11
 */
public class DocumentConfig {
    private String projectName;
    private String moduleName;
    private String preUrl;
    private JSONObject header;
    //内容模板路径
    private String contentTemplatePath;

    protected static DocumentConfig initDocumentConfig(Properties prop){
        DocumentConfig documentConfig = new DocumentConfig();
        documentConfig.setPreUrl(prop.getProperty(Constant.DOCUMENT_PRE_URL));
        JSONObject headerJson = JSONObject.parseObject(prop.getProperty(Constant.DOCUMENT_HEADER));
        documentConfig.setHeader(headerJson);
        documentConfig.setProjectName(prop.getProperty(Constant.DOCUMENT_PROJECT_NAME));
        documentConfig.setModuleName(prop.getProperty(Constant.DOCUMENT_MODULE_NAME));
        documentConfig.setContentTemplatePath(prop.getProperty(Constant.DOCUMENT_CONTENT_TEMPLATE));
        return documentConfig;
    }

    protected void validityCheck(){

    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getModuleName() {
        return moduleName;
    }

    public String getContentTemplatePath() {
        return contentTemplatePath;
    }

    public void setContentTemplatePath(String contentTemplatePath) {
        this.contentTemplatePath = contentTemplatePath;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getPreUrl() {
        return preUrl;
    }

    public void setPreUrl(String preUrl) {
        this.preUrl = preUrl;
    }

    public JSONObject getHeader() {
        return header;
    }

    public void setHeader(JSONObject header) {
        this.header = header;
    }
}
